﻿@using System.Linq
@using Nancy.Security
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<System.Collections.Generic.IEnumerable<NancyUserManager.Models.Users>>

@{
    Layout = "Shared/_Layout.cshtml";
}

<h4>Users</h4>
<table class="table table-condensed table-hover">
    <thead><tr>
        <th>User Name</th><th>First</th><th>Last</th><th>Role</th><th>Created</th><th></th><th></th><th></th></tr>
    </thead>
    <tbody>
        
        @foreach (var u in Model)
        {
            <tr>
                <td>@u.Email</td>
                <td>@u.FirstName</td>
                <td>@u.LastName</td>
                <td>@u.RoleName</td>
                <td>@u.CreatedDate</td>
                <td><a href="/EditUser/@u.Guid"><span class="glyphicon glyphicon-edit"></span> Edit</a></td>
                
                
                @if (Html.RenderContext.Context.CurrentUser.IsAuthenticated())
                {
                    if (Html.RenderContext.Context.CurrentUser.Claims.Contains("Admin"))
                    {
                        if (u.Email != "admin@admin.com")
                        {
                            <td><a href="/EditUserRole/@u.Guid"> <span class="glyphicon glyphicon-user"></span> Change Role</a></td>
                            <td><a href="/DeleteUser/@u.Guid"><span class="glyphicon glyphicon-trash"></span> Delete</a></td>
                        }
                    }
                    else
                    {
                        <td></td>
                        <td></td>

                    }
                }
            </tr>
        }
    </tbody>
</table>